<template>
	<view>
		<view class="top">
			<view class="uni-form-item uni-column">
                <view class="title">提现金额</view>
				<view class="yuan">¥</view>
                <input class="uni-input uni-input_top" type="number" placeholder="请输入提现金额" v-model="commission_ok"  />
            </view>
			<view class="top_two" >可提现金额<text class="top_right" v-cloak>{{money}}</text></view>
		</view>
		<view class="foot">
			<view class="uni-form-item uni-column">
		        <view class="get_way">提现方式</view>
		    </view>
			<view class="getit">
				<image src="http://easycolor.juxingqiansheng.com/addons/ewei_shopv2/static/images/yinhangka.png" mode="" class="img"></image>
				<text class="getit_card">提现到银行卡</text>
				<label>
					<checkbox value="cb" color="#FFCC33" style="transform:scale(0.7)" class="radio" @click="check"/>
				</label>
			</view>
			<view class="show" :style="{display:boolean}">
				<view class="same">
					<view class="name">姓名</view>
					<input class="uni-input uni-input_cell" type="number" placeholder="请输入姓名" v-model="realname"/>
				</view>
				<view class="same" @click="bank_out">
					<view class="name">选择银行</view>
					<view class="bank">
						<view class="bank_online" v-cloak>{{bankname}}</view>
						<view :style="{display:bankout}" class="out_miss_father">
							<view v-for="(arr,index) in arrs" :key=index @click.stop="bank_miss(index)" class="list" v-cloak>{{arr}}</view>
						</view>
					</view>
				</view>
				<view class="same">
					<view class="name">银行卡支行</view>
					<input class="uni-input uni-input_cell" type="number" placeholder="请输入银行卡支行" v-model="bankzh" />
				</view>
				<view class="same">
					<view class="name">银行卡号</view>
					<input class="uni-input uni-input_cell" type="number" placeholder="请输入银行卡号" v-model="bankcard" />
				</view>
				<view class="same">
					<view class="name">确认卡号</view>
					<input class="uni-input uni-input_cell" type="number" placeholder="请确认卡号" v-model="bankcard1" />
				</view>
				
			</view>
			<button class="next" @click="jump">申请提现</button>
		</view>
	</view>
</template>

<script>
	export default {
		components: {
		},
		data() {
			return {
				res:[],
				openid:'',
				money:'',
				active:"active",
				checked:'checked',
				boolean: 'block',
				bankout: 'none',
				arrs:['工商银行', '农业银行', '建设银行', '平安银行', '中国银行', '交通银行'],
				commission_ok:'',
				// 死的？	
				type:3,
				realname:'',
				bankname:'工商银行',
				bankzh:'',
				bankcard:'',
				bankcard1:'',
			};
		},
		onLoad:function(){
			uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					
					this.setAjax()
					
				},
				fail: () => {
					uni.navigateTo({
						url: '../login/login'
					});
				}
			});
		},
		methods:{
			setAjax(){
				uni.request({
					url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=acommsion&app=1',
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						console.log(res)
						this.realname = res.data.last_data.realname
						this.bankname = res.data.last_data.bankname
						this.bankzh = res.data.last_data.bankzh
						this.bankcard = res.data.last_data.bankcard
						this.bankcard1 = this.bankcard
						uni.hideLoading()
						this.money = res.data.a_kzp
					},
					fail: () => {},
					complete: () => {}
				});
			},
			check() {
				this.boolean = this.boolean == 'block' ? 'none': 'block'
			},
			bank_out() {
				this.bankout = 'block'
			},
			bank_miss(index) {
				this.bankname = this.arrs[index]
				this.bankout = 'none'
			},
			jump() {
				if (this.commission_ok == '') {
					uni.showModal({title:'请输入提现金额',showCancel: false})
					return
				}
				if (this.realname == '') {
					uni.showModal({title:'请输入名字',showCancel: false})
					return
				}
				if (this.bankzh == '') {
					uni.showModal({title:'请输入银行卡支行',showCancel: false})
					return
				}
				if (this.bankcard == '') {
					uni.showModal({title:'请输入银行卡号',showCancel: false})
					return
				}
				if (this.bankcard1 == '') {
					uni.showModal({title:'请确认卡号',showCancel: false})
					return
				}
				uni.request({
					url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=commission.applya&app=1&openid='+this.openid,
					method: 'POST',
					data: {'openid':this.openid,'commission_ok':this.commission_ok,'type':3,'realname':this.realname,'bankname':this.bankname,'bankzh':this.bankzh,'bankcard':this.bankcard,'bankcard1':this.bankcard1},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						console.log(res)
						uni.hideLoading()
						// 弹窗
						uni.showModal({
						title:'提示',
						content:'确认要提现到银行卡?\r\n姓名:'+this.realname+'\r\n'+this.bankname+'卡号'+this.bankcard,
						showCancel: false,
						confirmColor:"#DD524D",
						success(res) {
							if (res.confirm) {
									setTimeout(function() {
										uni.showModal({
											title:'提现申请已提交',
											showCancel: false,
											success() {
												uni.navigateTo({
													url: '../acommsion'
												})
											}
										})
									}, 800);
								}
							}
						})
					},
					fail: () => {},
					complete: () => {}
				})
				
				uni.navigateTo({
					url: './application'
				})
			}
		}
	}
</script>

<style>
.top {
	margin-top: 30upx;
	background-color: #fff;
	padding: 0 20upx;
}
.uni-form-item {
	position: relative;
}
.uni-input_top {
	margin-left: 50upx;
	height: 100upx;
	line-height: 100upx;
	font-size: 40upx;
	border-bottom: 1upx solid #eee;
}
.yuan {
	position: absolute;
	top: 100upx;
	font-size: 44upx;
	font-weight: 555;
	left: 20upx;
}
.top_two {
	height: 80upx;
	line-height: 80upx;
	margin-left: 20upx;
	color: #555;
}
.top_right {
	margin-left: 50upx;
}
.foot {
	background-color: #FFFFFF;
	margin-top: 30upx;
}
.get_way {
	margin-left: 30upx;
	border-bottom: 2upx solid #eee;
}
.img {
	width: 50upx;
	height: 50upx;
	margin-left: 30upx;
	margin-top: 30upx;
}
.getit {
	position: relative;
	height: 100upx;
	border-bottom: 2upx solid #eee;
}
.getit_card {
	position: absolute;
	top: 30upx;
	left: 100upx;
}
.radio {
	position: absolute;
	top: 30upx;
	right: 25upx;
}
.show {
	background-color: #fff;
}
.same {
	height: 80upx;
	display: flex;
	margin: 20upx;
	padding-bottom: 20upx;
	border-bottom: 1upx solid #eee;
}
.name {
	flex: 1;
	padding-top: 16upx;
}
.uni-input_cell {
	flex: 3;
}
.bank {
	flex: 3;
	position: relative;
}
.bank_online {
	position: absolute;
	left: 10upx;
	top: 16upx;
}
.out_miss_father {
	position: absolute;
	top: 58upx;
	left: 10upx;
	z-index: 99999;
	width: 400upx;
	border: 1upx solid #ccc;
	background-color: #fff;
}
.next {
	margin: 20upx;
	border-radius: 15upx;
	background-color: #ff8507;
	color: #fff;
}
.list {
	height: 60upx;
	line-height: 60upx;
}
</style>
